package com.serenegiant.usbcameratest0;

import android.content.Context;
import android.hardware.usb.UsbDevice;
import android.os.Environment;
import android.view.Surface;
import android.view.SurfaceView;

import com.serenegiant.usb.IFrameCallback;
import com.serenegiant.usb.UVCCamera;

import java.io.File;
import java.nio.ByteBuffer;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
import java.util.concurrent.ThreadFactory;

public final class UVCCameraSession implements IFrameCallback {

    private static final String TAG = "UVCCameraSession";
    private final ExecutorService executorService;
    private final Context context;
    public UsbDevice usbDevice;
    public UVCCamera uvcCamera;
    public boolean isActive, isPreview;
    public Surface previewSurface;
    public SurfaceView surfaceView;
    private byte[] buffer;
    File usbCamera = new File(Environment.getExternalStorageDirectory(), "usbCamera");


    public UVCCameraSession(UsbDevice device, Context context) {
        this.context = context;
        this.usbDevice = device;
        executorService = Executors.newFixedThreadPool(1, new ThreadFactory() {
            @Override
            public Thread newThread(Runnable r) {
                return new Thread(r, "UVCCameraSession-" + device.getDeviceName());
            }
        });
        if (!usbCamera.exists()) {
            usbCamera.mkdir();
        }
    }

    private File dir = new File(Environment.getExternalStorageDirectory(), "usbcamera2");
    private byte[] uv;

    @Override
    public void onFrame(ByteBuffer frame) {


    }

    private long millis;
}
